//
//  PMDialog.cpp
//
//  Copyright (C) 2007 Visual.Wei
//  Author: Wei Shuai <cpuwolf@sina.com>
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
//

#include <windows.h>
#include <commctrl.h>
#include "progbar.h"
#include "PMDialog.h"
//------------------------------------------------
PMDialog::PMDialog(HWND hWnd,LPCTSTR lpTemplate,DLGPROC DialogProc):PMControl()
{
	g_hwnd=CreateDialog(g_hInst,lpTemplate,hWnd,DialogProc);
	g_pDialogFunc=DialogProc;
	Update();
	ReSize();
	ShowWindow(g_hwnd,SW_SHOW);
}
DWORD PMDialog::ReSize()
{
	RECT rect,irect;
	
	//get parent window handler
	GetClientRect(g_hpwnd,&rect);
	TabCtrl_GetItemRect(g_hpwnd,0,&irect);
	rect.top+=(irect.bottom-irect.top+4);
	rect.bottom-=4;
	rect.left+=4;
	rect.right-=4;
	MoveWindow(g_hwnd,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,true);
	return 0;
}
DWORD PMDialog::ReSize(HWND hWnd)
{
	RECT rect,irect;
	HWND hpwnd;
	
	//get parent window handler
	hpwnd=GetParent(hWnd);
	GetClientRect(hpwnd,&rect);
	TabCtrl_GetItemRect(hpwnd,0,&irect);
	rect.top+=(irect.bottom-irect.top+4);
	rect.bottom-=4;
	rect.left+=4;
	rect.right-=4;
	MoveWindow(hWnd,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,true);
	return 0;
}